package com.zy.ivideo.controller;

import com.zy.ivideo.entity.BulletScreenEntity;
import com.zy.ivideo.entity.CommentEntity;
import com.zy.ivideo.entity.ResponseEntity;
import com.zy.ivideo.service.BulletScreenService;
import com.zy.ivideo.token.UserToken;
import com.zy.ivideo.utils.ResponseUtils;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/bulletscreen")
@Api(value = "弹幕模块API接口", description = "该模块提供弹幕模块服务", tags = "弹幕模块")
public class BulletScreenController {
    @Autowired
    BulletScreenService service;

    /**
     * 发布弹幕信息
     * @param entity
     * @return
     */
    @UserToken
    @ApiOperation(value = "发布弹幕信息", notes = "发布弹幕信息", httpMethod = "POST")
    @PostMapping("/publishBulletScreen")
    public ResponseEntity<BulletScreenEntity> publishBulletScreen(@RequestBody
                                                                      @ApiParam(value = "弹幕实体", name = "entity", required = true)
                                                                        BulletScreenEntity entity){
        return service.publishBulletScreen(entity);
    }

    /**
     * 删除弹幕信息
     * @param id
     * @return
     */
    @UserToken
    @ApiOperation(value = "删除弹幕信息", notes = "删除弹幕信息", httpMethod = "DELETE")
    @DeleteMapping("/removeBulletScreen")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(dataType = "Long", name = "id", value = "弹幕id", required = true),
    })
    public ResponseEntity<Boolean> removeBulletScreen(Long id){
        return service.removeBulletScreen(id);
    }

    /**
     * 获取弹幕信息
     * @param datatype 数据类型 0-simplevideo 1-multitypevideo
     * @param itemid 资源id
     * @return
     */
    @UserToken
    @ApiOperation(value = "获取弹幕信息", notes = "获取弹幕信息", httpMethod = "GET")
    @GetMapping("/getBulletScreenInfo")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(dataType = "int", name = "datatype", value = "数据类型 0-simplevideo 1-multitypevideo", required = true),
            @ApiImplicitParam(dataType = "String", name = "itemid", value = "资源id", required = true)
    })
    public ResponseEntity<List<BulletScreenEntity>> getBulletScreenInfo(int datatype, String itemid){
        return service.getBulletScreenInfo(datatype,itemid);
    }
}
